<%--
  Created by IntelliJ IDEA.
  User: hp
  Date: 2024/12/2
  Time: 09:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--html css js jquery bootstarp--%>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript">
  function register(){
    let username=document.getElementById("username").value;
    let address=document.getElementById("address").value;
    //json data
    let jsonData={"username":username,"address":address}
    //convert to json obj
    let jsonObj=JSON.stringify(jsonData);

    $.ajax({
      type:'POST',
      contentType:'application/json;charest=utf-8',
      data: jsonObj,
      url:'${pageContext.request.contextPath}/stu/insert.do',
      success:function(respData){
        //todo
        alert(respData.username + ":" + respData.address)
      },
    })
  }
</script>

<html>
<head>
    <title>Title</title>
</head>
<body>
用户名：<input type="text" name="username" id="username"><br>
密码：<input type="text" name="address" id="address"><br>
<input type="button" value="注册" onclick="register()">
</body>
</html>
